<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8" language="java"
	import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/base.jsp"%>
<%@ taglib prefix="d" uri="/doone-comm-ui-tags"%>

<html>
	<head>
		<title>详情信息管理</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link type="text/css" href="../manage/css/layout.css" rel="stylesheet" />
		<link type="text/css" href="../manage/css/new_style.css"
			rel="stylesheet" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/manage/css/zTreeStyle.css" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/manage/css/colorbox.css" />
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-1.4.4.min.js"></script>

		<script type="text/javascript"
			src="<%=path%>/manage/js/easyTooltip.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-ui-1.8.11.custom.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.wysiwyg.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/hoverIntent.js"></script>
		<script type="text/javascript" src="<%=path%>/manage/js/superfish.js"></script>
		<script type="text/javascript" src="<%=path%>/manage/js/custom.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.ztree.core-3.1.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.colorbox-min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery_form.js"></script>
	</head>
	<script type="text/javascript">
	  function delContentDetail(productId,intContentId,intCateId){
	 	if (confirm("慎重考虑是否确定删除该记录?删除后无法查看该条记录！！！")) {
	 		//检测内容是否被绑定
	 		$.get(root + '/dataBinding/checkIfContentIsBinded.action',{'intContentId' : intContentId},function(data){
	 			if(data=="true"){
	 				if(confirm("该条记录已经被页面绑定，删除将会解绑，是否继续删除？")){
	 					deleteContent(productId,intContentId,intCateId,"true");
	 				}
	 			} else {
	 				deleteContent(productId,intContentId,intCateId,"false");
	 			}
	 		});
		}
	}
	
	function deleteContent(productId,intContentId,intCateId,isBinded) {
		$.ajax({
			url : root + '/dataBinding/goDelContentDetail.action',
			method : 'post',
			data : {
				'intContentId' : intContentId,
				'isBinded' : isBinded,
				'productId' : productId
			},
			success : function(data) {

				window.location.href = root
						+ '/dataBinding/getAppContent.action?intCateId='+intCateId;
			},
			error : function(err) {
				if (err.responseText != '')
					alert(err.responseText);
				else
					alert("请求失败！");
			}
		});
	}
	
	function refreshData(intCateId) {
		window.location.href = root + '/dataBinding/getAppContent.action?intCateId='+intCateId;
	}
	
	function doDataTop(productId,intContentId,intCateId){
		$.ajax({
			url : root+'/dataBinding/doDataTop.action?intContentId='+intContentId+'&intCateId='+intCateId+'&productId='+productId,
			method : 'post',
			dataType : 'json',
			success : function(data) {
				if(data==null){
					$("#topOpr"+intContentId).html("取消置顶");
					$("#topOpr"+intContentId).attr("href","javascript:doCancelDataTop("+productId+","+intContentId+","+intCateId+")");
					refreshData(intCateId);
				}
			},
			error:function(err){
				if(err.responseText!='')
					alert(err.responseText);
				else
					alert("请求失败！");
			}
		});
	}
	
	function doCancelDataTop(productId,intContentId,intCateId) {
		$.ajax({
			url : root+'/dataBinding/doCancelDataTop.action?intContentId='+intContentId+'&productId='+productId,
			method : 'post',
			dataType : 'json',
			success : function(data) {
				if(data==null){
					$("#topOpr"+intContentId).html("置顶");
					$("#topOpr"+intContentId).attr("href","javascript:doDataTop("+productId+","+intContentId+","+intCateId+")");
					refreshData(intCateId);
				}
			},
			error:function(err){
				if(err.responseText!='')
					alert(err.responseText);
				else
					alert("请求失败！");
			}
		});
	}
	</script>
	<body>
		<div>
			<p class="sitemap">
				当前位置：电商管理 
			</p>
			<h1>
				商品列表查看
			</h1>
			<div>
				<!-- Tabs -->
				<div id="tabs">
					<ul>
						<li>
							<a href="#tabs-1">商品列表</a>
						</li>

					</ul>
					<s:hidden name="intCateId"></s:hidden>
					<div>
						<a class="btn_addnew"
							href="<%=path%>/dataBinding/goEcEdit.action?intCateId=<s:property value="intCateId"/>&fromUrl=add">添加商品</a>
						<br>
					</div>

					<table class="fullwidth" cellpadding="0" cellspacing="0" border="0">
						<thead>
							<tr>
								<td>
									缩略图
								</td>
								<td>
									名称
								</td>
								<td>
									描述
								</td>
								<td>
									销售价
								</td>
								<td>
									数量
								</td>
								<td>
									发布时间
								</td>
								<td>
									更新时间
								</td>
								<td>
									<span>操作<img alt="刷新"
											onclick="refreshData(<s:property value="intCateId"/>);"
											title="刷新数据和顺序"
											style="width: 16px; height: 16px; margin-left: 8px; vertical-align: bottom;"
											src="<%=path%>/images/refresh.png" />
									</span>
								</td>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="products">
								<tr class="odd">
									<td>
										<img alt="" src="<%=serverUrl %><s:property value="ecProduct.thumbImage" />"
											width="76" height="53">
									</td>

									<td>
										<s:if test="ecProduct.title.length()>20">
											<s:property value="ecProduct.title.substring(0,10)" />...
										</s:if>
										<s:else>
											<s:property value="ecProduct.title" />
										</s:else>
									</td>
									<td>
										<s:if test="ecProduct.summary.length()>20">
											<s:property value="ecProduct.summary.substring(0,10)" />...
										</s:if>
										<s:else>
											<s:property value="ecProduct.summary" />
										</s:else>
									</td>
									<td>
										<s:property value="ecProduct.price" />
									</td>
									<td>
										<s:property value="ecProduct.storeQuantity" />
									</td>
									<td>
										<s:property value="ecProduct.createDt" />
									</td>
									<td>
										<s:property value="ecProduct.updateDt" />
									</td>
									<td>
										<a class="icon icon_edit" title="编辑"
											href="<%=path%>/dataBinding/goEcEdit.action?intContentId=<s:property value='intContentId' />&productId=<s:property value="ecProduct.id"/>&fromUrl=edit"></a>

										<a class="icon icon_delete" title="删除 "
											href="javascript:delContentDetail('<s:property value="ecProduct.id"/>','<s:property value="intContentId" />','<s:property value="ecProduct.catId"/>')"></a>

										<s:if test="ecProduct.sortOrders>0">
											<a id="topOpr<s:property value='intContentId'/>"
												style="text-decoration: none; margin: 5px; white-space: nowrap;"
												href="javascript:doCancelDataTop(<s:property value="ecProduct.id"/>,<s:property value="intContentId" />,<s:property value="ecProduct.catId"/>)">取消置顶</a>
										</s:if>
										<s:else>
											<a id="topOpr<s:property value='intContentId'/>"
												style="text-decoration: none; margin: 5px; white-space: nowrap;"
												href="javascript:doDataTop(<s:property value="ecProduct.id"/>,<s:property value="intContentId" />,<s:property value="ecProduct.catId"/>)">置顶</a>
										</s:else>
									</td>

								</tr>
							</s:iterator>
						</tbody>
					</table>
				</div>
				<!-- 分页标签开始 -->
				<div align="right" style="float: right;">
					<d:page id="pageContent" template="details" skin="gray">
					</d:page>

				</div>
			</div>
			<!-- 分页标签结束 -->

		</div>
	</body>
</html>
